﻿using CleanArchitecture.Core.SharedKernel;
using CleanArchitecture.Infrastructure.Entities.Business;
using CleanArchitecture.Infrastructure.Entities.System.DataDic;
using CleanArchitecture.Infrastructure.Entities.SystemModules;
using System;
using System.Collections.Generic;

namespace CleanArchitecture.Infrastructure.Entities.AdminUsers
{
    /// <summary>
    /// Represents a setting
    /// </summary>
    public partial class AdminRole : BaseEntity
    {
        #region Field
        /// <summary>
        /// DavidLee 2019/11/23命名符合EF Core驼峰规范，否则报错，见AdminUser说明
        /// </summary>
        private ICollection<AdminRoleSystemModuleMapping> _adminroleSystemModuleMappings;
        private ICollection<AdminRoleBusColumnMapping> _adminroleBusinessColumnMappings;
        #endregion

        #region Ctor
        /// <summary>
        /// Ctor
        /// </summary>
        public AdminRole()
        {
        }
        #endregion

        #region Property
        /// <summary>
        /// 用户角色名称
        /// </summary>
        public string RoleName { get; set; }

        /// <summary>
        /// 角色所属机构组织名称
        /// </summary>
        public int FKOrganizeId { get; set; }

        /// <summary>
        /// 角色是否正常使用 1-激活正常 0-删除或注销
        /// </summary>
        public EntityEnumConfig.YesorNo IsActive { get; set; }

        /// <summary>
        /// 角色是否是超级管理员，超级管理员有绝对权限，无需验证角色对应模块判定授权状态
        /// </summary>
        public EntityEnumConfig.YesorNo IsAdmin { get; set; }

        public int DisplayOrder { get; set; }

        public DateTime CreatedOnTimeUtc { get; set; }

        #endregion Property
        public virtual SystemDataDicTree Organize { get; set; }
        /// <summary>
        /// Gets or sets the adminrole-sysmodule mappings
        /// </summary>
        public virtual ICollection<AdminRoleSystemModuleMapping> AdminroleSystemModuleMappings
        {
            get => _adminroleSystemModuleMappings ?? (_adminroleSystemModuleMappings = new List<AdminRoleSystemModuleMapping>());
            protected set => _adminroleSystemModuleMappings = value;
        }

        public virtual ICollection<AdminRoleBusColumnMapping> AdminroleBusinessColumnMappings
        {
            get => _adminroleBusinessColumnMappings ?? (_adminroleBusinessColumnMappings = new List<AdminRoleBusColumnMapping>());
            protected set => _adminroleBusinessColumnMappings = value;
        }
    }

    /// <summary>
    /// DavidLee 2020/02/17 增加无映身关系的用户角色，减少LazyLoading造成的系统崩溃问题
    /// </summary>
    //public partial class AdminRoleNoMapping : BaseEntity
    //{
    //    #region Ctor
    //    /// <summary>
    //    /// Ctor
    //    /// </summary>
    //    public AdminRoleNoMapping()
    //    {
    //    }
    //    #endregion

    //    #region Property
    //    /// <summary>
    //    /// 用户角色名称
    //    /// </summary>
    //    public string RoleName { get; set; }

    //    /// <summary>
    //    /// 角色所属机构组织名称
    //    /// </summary>
    //    public int FKOrganizeId { get; set; }

    //    /// <summary>
    //    /// 角色是否正常使用 1-激活正常 0-删除或注销
    //    /// </summary>
    //    public EntityEnumConfig.YesorNo IsActive { get; set; }

    //    /// <summary>
    //    /// 角色是否是超级管理员，超级管理员有绝对权限，无需验证角色对应模块判定授权状态
    //    /// </summary>
    //    public EntityEnumConfig.YesorNo IsAdmin { get; set; }

    //    public int DisplayOrder { get; set; }

    //    public DateTime CreatedOnTimeUtc { get; set; }

    //    #endregion Property
    //    public virtual SystemDataDicTree Organize { get; set; }
    //}
}
